package org.smoozik.app.mode.rythmtrainer;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import javax.sound.midi.Instrument;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.LayoutStyle.ComponentPlacement;

import org.smoozik.app.ihm.Constants;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.FlowLayout;

@SuppressWarnings("serial")
public class ButtonsPanel extends JPanel {

	public ButtonsPanel(RythmTrainerMode mode) {
		super();

		this.setBackground(Color.DARK_GRAY);

		JButton playButton = new JButton(Constants.PLAY_LABEL);
		playButton.addActionListener(mode.rythmTrainerListener);
		JButton pauseButton = new JButton(Constants.PAUSE_LABEL);

		// File buttons
		// JLabel file = new JLabel("File");
		// file.setForeground(Color.LIGHT_GRAY);
		// buttons.add(file);
		pauseButton.addActionListener(mode.rythmTrainerListener);
		JButton doneButton = new JButton(Constants.DONE_LABEL);

		doneButton.addActionListener(mode.rythmTrainerListener);
		JButton stopButton = new JButton(Constants.STOP_LABEL);
		stopButton.addActionListener(mode.rythmTrainerListener);
		JButton openButton = new JButton(Constants.OPEN_LABEL);
		openButton.addActionListener(mode.rythmTrainerListener);
		JButton reloadButton = new JButton(Constants.RELOAD_LABEL);
		reloadButton.addActionListener(mode.rythmTrainerListener);
		JButton saveButton = new JButton(Constants.SAVE_LABEL);
		saveButton.addActionListener(mode.rythmTrainerListener);

		JButton genButton = new JButton(Constants.GEN_LABEL);
		genButton.addActionListener(mode.rythmTrainerListener);
		JButton recButton = new JButton(Constants.REC_LABEL);
		recButton.addActionListener(mode.rythmTrainerListener);
		JLabel sound1 = new JLabel("S 1");
		sound1.setForeground(Color.LIGHT_GRAY);
		JLabel tick = new JLabel("Tick");
		tick.setForeground(Color.LIGHT_GRAY);

		JLabel scroll = new JLabel("Scroll");
		scroll.setForeground(Color.LIGHT_GRAY);

		JLabel sound0 = new JLabel("S 0");
		sound0.setForeground(Color.LIGHT_GRAY);

		GroupLayout groupLayout = new GroupLayout(this);
		groupLayout
				.setHorizontalGroup(groupLayout
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								groupLayout
										.createSequentialGroup()
										.addGap(92)
										.addGroup(
												groupLayout
														.createParallelGroup(
																Alignment.TRAILING)
														.addGroup(
																groupLayout
																		.createSequentialGroup()
																		.addComponent(
																				sound0)
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				mode.instruments0,
																				GroupLayout.PREFERRED_SIZE,
																				GroupLayout.DEFAULT_SIZE,
																				GroupLayout.PREFERRED_SIZE))
														.addGroup(
																groupLayout
																		.createSequentialGroup()
																		.addComponent(
																				sound1)
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				mode.instruments1,
																				GroupLayout.PREFERRED_SIZE,
																				GroupLayout.DEFAULT_SIZE,
																				GroupLayout.PREFERRED_SIZE)))
										.addPreferredGap(
												ComponentPlacement.RELATED)
										.addGroup(
												groupLayout
														.createParallelGroup(
																Alignment.LEADING,
																false)
														.addComponent(
																genButton,
																Alignment.TRAILING,
																GroupLayout.DEFAULT_SIZE,
																GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																openButton,
																Alignment.TRAILING,
																GroupLayout.DEFAULT_SIZE,
																GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE))
										.addPreferredGap(
												ComponentPlacement.RELATED)
										.addGroup(
												groupLayout
														.createParallelGroup(
																Alignment.TRAILING,
																false)
														.addComponent(
																playButton,
																GroupLayout.PREFERRED_SIZE,
																65,
																GroupLayout.PREFERRED_SIZE)
														.addComponent(
																reloadButton,
																Alignment.LEADING))
										.addPreferredGap(
												ComponentPlacement.RELATED,
												GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)
										.addGroup(
												groupLayout
														.createParallelGroup(
																Alignment.LEADING,
																false)
														.addComponent(
																stopButton,
																GroupLayout.DEFAULT_SIZE,
																GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																saveButton,
																GroupLayout.DEFAULT_SIZE,
																GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE))
										.addPreferredGap(
												ComponentPlacement.RELATED)
										.addGroup(
												groupLayout
														.createParallelGroup(
																Alignment.LEADING)
														.addGroup(
																Alignment.TRAILING,
																groupLayout
																		.createSequentialGroup()
																		.addComponent(
																				tick)
																		.addPreferredGap(
																				ComponentPlacement.UNRELATED)
																		.addComponent(
																				mode.tickBox)
																		.addGap(12))
														.addComponent(
																pauseButton))
										.addPreferredGap(
												ComponentPlacement.RELATED,
												GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)
										.addGroup(
												groupLayout
														.createParallelGroup(
																Alignment.LEADING)
														.addGroup(
																groupLayout
																		.createSequentialGroup()
																		.addGap(6)
																		.addComponent(
																				recButton)
																		.addGap(6)
																		.addComponent(
																				doneButton))
														.addGroup(
																groupLayout
																		.createSequentialGroup()
																		.addGap(10)
																		.addComponent(
																				scroll)
																		.addPreferredGap(
																				ComponentPlacement.UNRELATED)
																				.addComponent(
																						mode.scrollBox)
																						.addComponent(
																								mode.songIds)))
										.addGap(382)));
		groupLayout
				.setVerticalGroup(groupLayout
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								groupLayout
										.createSequentialGroup()
										.addGap(9)
										.addGroup(
												groupLayout
														.createParallelGroup(
																Alignment.BASELINE)
														.addComponent(
																playButton)
														.addComponent(genButton)
														.addComponent(
																mode.instruments0,
																GroupLayout.PREFERRED_SIZE,
																GroupLayout.DEFAULT_SIZE,
																GroupLayout.PREFERRED_SIZE)
														.addComponent(sound0)
														.addComponent(
																stopButton)
														.addComponent(
																pauseButton)
														.addComponent(recButton)
														.addComponent(
																doneButton))
										.addGap(7)
										.addGroup(
												groupLayout
														.createParallelGroup(
																Alignment.TRAILING)
														.addGroup(
																groupLayout
																		.createParallelGroup(
																				Alignment.BASELINE)
																		.addComponent(
																				openButton)
																		.addComponent(
																				saveButton)
																		.addComponent(
																				mode.instruments1,
																				GroupLayout.PREFERRED_SIZE,
																				GroupLayout.DEFAULT_SIZE,
																				GroupLayout.PREFERRED_SIZE)
																		.addComponent(
																				sound1)
																		.addComponent(
																				scroll)
																		.addComponent(
																				reloadButton)
																		.addComponent(
																				tick))
														.addComponent(
																mode.scrollBox)
																.addComponent(
																		mode.tickBox)
																		.addComponent(
																				mode.songIds))
										.addContainerGap(231, Short.MAX_VALUE)));
		setLayout(groupLayout);

	}

}
